#ifndef _NE_MD2_MODEL_LOADER_H_
#define _NE_MD2_MODEL_LOADER_H_

#include <graphics/MD2Model.h>

namespace ne
{
    class MD2ModelLoader
    {
        public:
            struct MD2Header
            {
                int m_iMagicNum;
                int m_iVersion;
                int m_iSkinWidthPx;
                int m_iSkinHeightPx;
                int m_iFrameSize;
                int m_iNumSkins;
                int m_iNumVertices;
                int m_iNumTexCoords;
                int m_iNumTriangles;
                int m_iNumGLCommands;
                int m_iNumFrames;
                int m_iOffsetSkins;
                int m_iOffsetTexCoords;
                int m_iOffsetTriangles;
                int m_iOffsetFrames;
                int m_iOffsetGlCommands;
                int m_iFileSize;
            };

            struct MD2AliasTriangle
            {
                byte m_vVertex[3];
                byte m_bLightNormalIndex;
            };

// This stores the normals and vertices for the frames
            struct MD2Triangle
            {
                float m_vVertex[3];
                float m_vNormal[3];
            };

// This stores the indices into the vertex and texture coordinate arrays
            struct MD2Face
            {
                short m_vVertexIndices[3];
                short m_vTextureIndices[3];
            };

// This stores UV coordinates
            struct MD2TexCoord
            {
                short u, v;
            };

// This stores the animation scale, translation and name information for a frame, plus verts
            struct MD2AliasFrame
            {
                float m_vScale[3];
                float m_vTranslate[3];
                char m_vName[16];
                MD2AliasTriangle m_vAliasVertices[1];
            };

// This stores the frames vertices after they have been transformed
            struct MD2Frame
            {
                char m_vFrameName[16];
                MD2Triangle *m_pVertices;
            };

// This stores a skin name
            typedef char MD2Skin[64];

        public:
            MD2ModelLoader() {};

            MD2Model* loadModel(const std::string &fileName) const;

            ~MD2ModelLoader() {};

            static const int MD2_MAGIC;
            static const int MD2_VERSION;
    };
}
#endif


